package com.example.soapserver.endpoint;

import com.example.soapserver.model.department.*;
import com.example.soapserver.service.impl.DepartmentWebServiceImpl;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

/**
 * 部门WebService端点
 */
@Endpoint
public class DepartmentServiceEndpoint {
    
    private static final String NAMESPACE_URI = "http://com.cssc.cn/webservice/department";
    
    private final DepartmentWebServiceImpl departmentService;
    
    public DepartmentServiceEndpoint(DepartmentWebServiceImpl departmentService) {
        this.departmentService = departmentService;
    }
    
    /**
     * 接收部门数据
     */
    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "receiveDeptDataRequest")
    @ResponsePayload
    public ReceiveDeptDataResponse receiveDeptData(@RequestPayload ReceiveDeptDataRequest request) {
        return departmentService.receiveDeptData(request);
    }
    
    /**
     * 根据部门编码获取部门信息
     */
    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "getDeptByCodeRequest")
    @ResponsePayload
    public GetDeptByCodeResponse getDeptByCode(@RequestPayload GetDeptByCodeRequest request) {
        return departmentService.getDeptByCode(request);
    }
    
    /**
     * 获取所有部门信息
     */
    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "getAllDeptsRequest")
    @ResponsePayload
    public GetAllDeptsResponse getAllDepts(@RequestPayload GetAllDeptsRequest request) {
        return departmentService.getAllDepts(request);
    }
    
    /**
     * 测试服务连通性
     */
    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "testServiceRequest")
    @ResponsePayload
    public String testService(@RequestPayload String request) {
        return departmentService.testService();
    }
}